//=======================================================
// 作者：KingSley
// 描述：通过OnComplete实现DOTween动画连续播放
//=======================================================
using UnityEngine;
using System.Collections;
using DG.Tweening;
using UnityEngine.UI;

namespace Babybus.Uno
{
    public class DOTweenOnComplete : MonoBehaviour
    {
        public Image[] obj;
        public Image[] target;
        int i = 0;

        private void Start()
        {
            SetP();
        }

        /// <summary>
        /// 通过OnComplete的递归实现多动画依次播放
        /// </summary>
        private void SetP()
        {
            obj[i].rectTransform.DOAnchorPos(target[i].rectTransform.anchoredPosition, 1.5f).OnComplete(() => {
                obj[i].transform.SetParent(target[i].transform);
                i++;
                if (i < obj.Length)
                {
                    SetP();
                }
            });
        }

    }
}
